package com.block.datapush.factory;

import com.block.common.util.ApplicationContextUtil;
import com.block.datapush.enums.PushApiEnum;
import com.block.datapush.service.IPushExtDataService;
import com.block.datapush.service.extdata.DefaultPushExtDataServie;
import com.block.datapush.service.extdata.QiDaiPushExtDataServie;
import com.block.datapush.service.extdata.ZhenXiangPushExtDataServie;

import java.util.HashMap;
import java.util.Map;

public class PushExtDataFactory {

    private static final Map<String, Class<? extends IPushExtDataService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(PushApiEnum.QIDAI.getValue(), QiDaiPushExtDataServie.class);
        serviceMap.put(PushApiEnum.COMMONAPIS.getValue(), ZhenXiangPushExtDataServie.class);
        serviceMap.put(PushApiEnum.XIAOANFENQIRATESSQ.getValue(), ZhenXiangPushExtDataServie.class);
    }

    public static IPushExtDataService getService(String pushType){
        if (serviceMap.containsKey(pushType)){
            Class<? extends IPushExtDataService> aClass = serviceMap.get(pushType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return ApplicationContextUtil.getBean(DefaultPushExtDataServie.class);
    }

}
